import os

import celery
import pymysql

from django.conf import settings

pymysql.install_as_MySQLdb()

project_name = 'fang'
# project_settings = '%s.settings' % project_name

# 注册环境变量
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fang.settings')

app = celery.Celery(project_name,
                    backend='amqp://jackfrued:123456@120.77.222.217:5672/myvhost',
                    broker='amqp://jackfrued:123456@120.77.222.217:5672/myvhost')


# 从默认的配置文件读取配置信息
app.config_from_object('django.conf:settings')

# Celery加载所有注册的应用
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

